/**
 * 
 */
package edu.cmu.cs.webapp.ioms.utils;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

import edu.cmu.cs.webapp.ioms.models.Ingredient;

/**
 * @author Christian
 * 
 */
public class IOMSUtils {

	public static String constructIngText(Ingredient model) {
		return model.getName() + "(#" + model.getIng_id() + ")";
	}

	public static int updateSortDirection(final TableColumn column) {
		Table table = column.getParent();
		if (column == table.getSortColumn()) {
			if (table.getSortDirection() == SWT.UP) {
				table.setSortDirection(SWT.DOWN);
			} else {
				table.setSortDirection(SWT.UP);
			}
		} else {
			table.setSortColumn(column);
			table.setSortDirection(SWT.DOWN);
		}
		return table.getSortDirection();
	}

}
